<?php if (!defined('TL_ROOT')) die('You can not access this file directly!');

$GLOBALS['TL_DCA']['tl_images_slider'] = array
( 
'config' => array
	(
		'dataContainer'               => 'Table',
		'ptable'					=> 'tl_group_slider'	
	), 

    // List
    'list' => array
    (
        'sorting' => array
        (
            'mode'                    => 4,
            'fields'                  => array('tstamp'),
        	'headerFields'            => array('title'),
            'panelLayout'             => 'filter;sort,search,limit',
        	'flag'                    => 1,
        	'child_record_callback'   => array('tl_sliders', 'listSliders')
        ),
        'label' => array
        (
			'fields'                  => array('image','name'),
			'format'                  => '<img src="%s" width="150" /> %s',
        ),
        'global_operations' => array
		(
			'all' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['MSC']['all'],
				'href'                => 'act=select',
				'class'               => 'header_edit_all',
				'attributes'          => 'onclick="Backend.getScrollOffset();" accesskey="e"'
			)
		),
        'operations' => array
		(
			'edit' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['MSC']['edit'],
				'href'                => 'act=edit',
				'icon'                => 'edit.gif',
			),
			'copy' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['MSC']['copy'],
				'href'                => 'act=copy',
				'icon'                => 'copy.gif',
			),
			'delete' => array
			(
				'label'               => &$GLOBALS['TL_LANG']['tl_images_slider']['delete'],
				'href'                => 'act=delete',
				'icon'                => 'delete.gif',
				'attributes'          => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"',
			)
		)
    ),

    // Palettes
	'palettes' => array
	(
		'default'                     => 'name,urlSlider,description,image',
	),
    
    // Fields
    'fields' => array
    (
    	'name' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_images_slider']['tt_name'],
			'search'                  => true,
			'flag'                    => 1,
			'inputType'               => 'text',
			'eval'                    => array('mandatory'=>true, 'maxlength'=>255, 'tl_class'=>'w50')
		),
		
		'description' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['tl_images_slider']['tt_description'],
			'exclude'                 => true,
			'inputType'               => 'textarea',
			'eval'                    => array('mandatory'=>true, 'rte'=>'tinyMCE', 'tl_class'=>'clr')
		),
		
		'image' => array
        (
            'label'						=> &$GLOBALS['TL_LANG']['tl_images_slider']['tt_image'],
            'inputType'					=> 'fileTree',
            'eval'						=> array('mandatory'=>true, 'files'=>true, 'filesOnly'=>true, 'fieldType'=>'radio', 'extensions'=>'jpg,png,gif,tif')
        ),
        'urlSlider' => array
		(
			'label'                   => &$GLOBALS['TL_LANG']['MSC']['url'],
			'exclude'                 => true,
			'search'                  => true,
			'inputType'               => 'text',
			'eval'                    => array('rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'tl_class'=>'w50 wizard'),
			'wizard' => array
			(
				array('tl_images_slider', 'pagePicker')
			)
		),
    )
);

class tl_images_slider extends Backend
{

	/**
	 * __construct
	 */
	public function __construct()
	{
		parent::__construct();
	}
	
public function pagePicker(DataContainer $dc)
	{
		$strField = 'ctrl_' . $dc->field . (($this->Input->get('act') == 'editAll') ? '_' . $dc->id : '');
		return ' ' . $this->generateImage('pickpage.gif', $GLOBALS['TL_LANG']['MSC']['pagepicker'], 'style="vertical-align:top; cursor:pointer;" onclick="Backend.pickPage(\'' . $strField . '\')"');
	}
	

}

class tl_sliders extends Backend {
	
	/**
	 * List cds of our collection
	 * @param array
	 * @return string
	 */
	public function listSliders($arrRow)
	{
		
		return "<img src='".$arrRow['image']."' width='150' /> ".$arrRow['name']."\n";
	}
	
}


?>
